how to use proxy in outlook2019(set proxy for a single application)

  1. testing

    • enable connection tab with lgp, but failed.

    • proxifier on command line, also failed except proxifier gui.

    • using pac file.

  2. result

    • crate a pac file, for examples:

      from cisco:

      function FindProxyForURL(url, host)
      {
      if (shExpMatch(host, "*.live.com"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.microsoft.com"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.office365.com"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.office.com"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.microsoftonline.com"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.msocdn.com"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.msftauth.net"))
      return "SOCKS chenshi.de:1080";
      else if (shExpMatch(host, "*.msauth.net"))
      return "SOCKS chenshi.de:1080";
      else
      return "DIRECT";
      }
      

      recommanded:

      function FindProxyForURL(url, host)
       {
       if (shExpMatch(host, "*.live.com") ||
       shExpMatch(host, "*.microsoft.com") ||
       shExpMatch(host, "*.office365.com") ||
       shExpMatch(host, "*.office.com") ||
       shExpMatch(host, "*.microsoftonline.com") ||
       shExpMatch(host, "*.msocdn.com") ||
       shExpMatch(host, "*.msftauth.net") ||
       shExpMatch(host, "*.msauth.net"))
       return "SOCKS chenshi.de:1080";
       else
       return "DIRECT";
       }
      

      not recommended:

      function FindProxyForURL(url, host)
       {
       if (shExpMatch(host, "(*.live.com|*.microsoft.com|*.office365.com|*.office.com|*.microsoftonline.com|*.msocdn.com|*.msftauth.net|*.msauth.net)"))
       return "SOCKS chenshi.de:1080";
       else
       return "DIRECT";
       }
      

      from v2ray, I like it:

      var V2Ray = “SOCKS5 chenshi.de:1080; SOCKS chenshi.de:1080; DIRECT;";
      var domains = [
      "live.com",
      "microsoft.com",
      "office365.com",
      "office.com",
      "microsoftonline.com",
      "msocdn.com",
      "msftauth.net",
      "msauth.net",
      ];
      function FindProxyForURL(url, host) {
          for (var i = domains.length - 1; i >= 0; i--) {
              if (dnsDomainIs(host, domains[i])) {
                  return V2Ray;
              }
          }
          return "DIRECT";
      }
      
    • set proxy with powershell:

      Function set-windowsAcs
      {
          Param
          (
              [string]$acs
          )
          Begin
          {
              $regKey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
          }
      
          Process
          {
              if ((Get-ItemProperty $regKey).PSObject.Properties.Name -contains "AutoConfigURL" -eq $true)
              {
              Remove-ItemProperty -path $regKey -Name AutoConfigURL
              }
              Set-ItemProperty -path $regKey -Name AutoConfigURL -Value $acs
          }
      
          End
          {
              Write-Output "pac is enabled"
          }
      }
      set-windowsAcs -acs https://chenshi.de/chenshi.pac
      
  3. references:

    https://findproxyforurl.com/example-pac-file/

    https://www.cisco.com/c/en/us/support/docs/security/web-security-appliance/118076-configure-wsa-00.html